	<?php 
		$ci= &get_instance();
		$listEventCategory = $ci->event_category_entity->getArrayListOfEventCategory($match_id);
		$eventCategoryStatus = eventCategoryStatusDataConfig();
		$eventStatus = eventStatusDataConfig();
		$betStatus = betStatusDataConfig();
		$iC = 0;
	?>
	<input type="hidden" name="dialog_mode" id="dialog_mode" value="hidden" />
	
	<div class="clrboth"></div>
	<div class="grid10" style="width:800px;">
		<input type="button" value="Add Category" onclick="add_category_event(<?php echo $match_id;?>);" />
		&nbsp;&nbsp;&nbsp;
		<input type="button" value="Add Event" onclick="add_event(<?php echo $match_id;?>);" />
		&nbsp;&nbsp;&nbsp;
		<a href="javascript:void(0);" onclick="view_event(<?php echo $match_id;?>);">Live/UpComing Events</a>
		&nbsp;&nbsp;
		<a href="javascript:void(0);" onclick="view_event_closed(<?php echo $match_id;?>);">Closed Events</a>
		&nbsp;&nbsp;
		<a href="javascript:void(0);" onclick="view_event_cancelled(<?php echo $match_id;?>);">Cancelled Events</a>
		&nbsp;&nbsp;
		<a href="javascript:void(0);" onclick="view_event_hidden_category(<?php echo $match_id;?>);">Hidden categories</a>
	</div>
	<br/><br/>
	<div class="clrboth"></div>
<table>
<thead>
	<th><div class="grid2"><span class="bold" style="font-weight:bold;">Category</span></div></th>
	<th><div class="grid2"><span class="bold" style="font-weight:bold;">Event</span></div></th>
	<th><div class="grid1"><span class="bold" style="font-weight:bold;">Odds</span></div></th>
	<th><div class="grid1"><span class="bold" style="font-weight:bold;">Bet Enable</span></div></th>
	<th><div class="grid1"><span class="bold" style="font-weight:bold;">Status</span></div></th>
	<th><div class="grid2"><span class="bold" style="font-weight:bold;">Result</span></div></th>
	<th><div class="grid1"><span class="bold" style="font-weight:bold;">Who<br/>bet</span></div></th>
	<th><div class="grid4"><span class="bold" style="font-weight:bold;">Manage</span></div></th>
</thead>	
<tbody>
	<div class="clrboth"></div>
	<?php foreach( $listEventCategory as $item ): ?>
		<?php 
			$EVENT_CATEGORY = clone_( $ci->event_category_entity->init('id',$item->id) );
			$eventArray = $ci->event_entity->getArrayListOfEvent($EVENT_CATEGORY->getId());
			$iC++;
			$style= ($iC %2 == 0) ? "":"";
		?>
		<?php if($EVENT_CATEGORY->getIsOpen() != 'yes'):?>
			<tr class="cat">	  
				<td><div class="grid2" <?php echo $style;?>><?php echo $EVENT_CATEGORY->getCategory(); ?></div></td>
				<td><div class="grid2" <?php echo $style;?>>&nbsp;</div></td>
				<td><div class="grid1" <?php echo $style;?>>&nbsp;</div></td>
				<td><div class="grid1" <?php echo $style;?>>&nbsp;</div></td>
				<td><div class="grid1" <?php echo $style;?>><?php echo $eventCategoryStatus[$EVENT_CATEGORY->getStatus()]; ?></div></td>
				<td><div class="grid2" <?php echo $style;?>>
						<img title="Ordering category?" src="<?php echo site_url('addons/default/modules/dataman/img/ordering.png') ?>" style="cursor:pointer;" onclick="javascript:openOrderingDialog(<?php echo $match_id;?>);" />
					</div>
				</td>
				<td><div class="grid1" <?php echo $style;?>>
					<?php if($EVENT_CATEGORY->getIsOpen() == 'yes'):?>
						<a href="javascript:void(0);" onclick="event_category_open_hide(<?php echo $EVENT_CATEGORY->getId();?>,<?php echo $match_id;?>)">Open</a>
					<?php else:?>
						<a href="javascript:void(0);" onclick="event_category_open_hide(<?php echo $EVENT_CATEGORY->getId();?>,<?php echo $match_id;?>)">Hide</a>
					<?php endif; ?>
				</div>
				</td>
				<td><div class="grid4" <?php echo $style;?>>
					<a href="javascript:void(0);" onclick="event_category_edit(<?php echo $EVENT_CATEGORY->getId();?>)"><?php echo lang('dataman.edit');?></a>
					|
					<a href="javascript:void(0);" onclick="event_category_cancel(<?php echo $EVENT_CATEGORY->getId();?>)" >Cancel</a>
					|
					<a href="javascript:void(0);" onclick="event_category_finish(<?php echo $EVENT_CATEGORY->getId();?>)" >Finish</a>
					| <b>Events:</b>
					<a href="javascript:void(0);" onclick="add_events_to_category(<?php echo $EVENT_CATEGORY->getId();?>,<?php echo $match_id;?>)">Add </a>
					|
					<a href="javascript:void(0);" onclick="edit_all_events_of_category(<?php echo $EVENT_CATEGORY->getId();?>,<?php echo $match_id;?>)">Edit</a>
				</div></td>			
			</tr>
		<?php endif;?>
		
		<div class="clrboth"></div>
		
		<?php foreach($eventArray as $evObj):?>
			<?php 
				$EVENT = $ci->event_entity->init('id',$evObj->id);
				$won = ($EVENT->getResult() == 'won') ? 'checked="checked"':'';
				$lost = ($EVENT->getResult() == 'lost') ? 'checked="checked"':'';
				$iC++;
				$style= ($iC %2 == 0) ? "":"";
			?>
		 <?php if($EVENT_CATEGORY->getIsOpen() != 'yes'):?>
		 <tr>
			<td><div class="grid2" <?php echo $style;?>>&nbsp;</div></td>
			<td><div class="grid2" <?php echo $style;?>><?php echo $EVENT->getName(); ?></div></td>
			<td><div class="grid1" <?php echo $style;?>><?php echo $EVENT->getOdds(); ?></div></td>
			<td><div class="grid1" <?php echo $style;?>><a href="javascript:void(0);" onclick="event_change_bet_status(<?php echo $EVENT->getId();?>,<?php echo $match_id;?>)"><?php echo $betStatus[$EVENT->getBetEnable()]; ?></a></div></td>
			<td><div class="grid1" <?php echo $style;?>><?php echo $eventStatus[$EVENT->getStatus()]; ?></div></td>
			<td><div class="grid2" <?php echo $style;?>>
				<input type="radio" name="event_<?php echo $EVENT->getId();?>" value="won" <?php echo $won;?> onclick="set_event_result(<?php echo $EVENT->getId();?>,'won');" />Won
				<input type="radio" name="event_<?php echo $EVENT->getId();?>" value="lost" <?php echo $lost;?> onclick="set_event_result(<?php echo $EVENT->getId();?>,'lost');" />Lost 
			</div></td>
			<td><div class="grid1" <?php echo $style;?>><a href="javascript:void(0);" onclick="who_bet_event(<?php echo $EVENT->getId();?>)">View</a></div></td>
			<td><div class="grid4" <?php echo $style;?>>
				<a href="javascript:void(0);" onclick="event_edit(<?php echo $EVENT->getId();?>,<?php echo $match_id;?>)"><?php echo lang('dataman.edit');?></a>
				&nbsp;|&nbsp;
				<a href="javascript:void(0);" onclick="event_cancel(<?php echo $EVENT->getId();?>)" >Cancel</a>
				&nbsp;|&nbsp;
				<a href="javascript:void(0);" onclick="event_finish(<?php echo $EVENT->getId();?>)" >Finish</a>
			</div></td>
		</tr>	
		 <?php endif;?>
			<div class="clrboth"></div>
		<?php endforeach;?>
	<?php endforeach; ?>
</tbody>
</table>	

